package com.cool.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import cn.beecp.BeeDataSource;

// import cn.beecp.BeeDataSource;

/**
 * @author bian
 * @date 2021-04-28
 */
@Configuration
public class BeeDataSourceConfig {
    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public BeeDataSource primaryDataSource() {
        return DataSourceBuilder.create().type(BeeDataSource.class).build();
    }

    // @Bean
    // public SqlSessionFactoryBean getSqlSessionFactoryBean(BeeDataSource da) {
    // SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    // sqlSessionFactoryBean.setDataSource(da);
    // // 设置分页的拦截器
    // PageInterceptor pageInterceptor = new PageInterceptor();
    // // 创建插件需要的参数集合
    // Properties properties = new Properties();
    // // 配置数据库方言 为oracle
    // properties.setProperty("helperDialect", "mysql");
    // // 配置分页的合理化数据
    // properties.setProperty("reasonable", "true");
    // pageInterceptor.setProperties(properties);
    // // 将拦截器设置到sqlSessionFactory中
    // sqlSessionFactoryBean.setPlugins(pageInterceptor);
    //
    // return sqlSessionFactoryBean;
    // }
}
